package com.wuseguang.springcloud.controller;

import com.wuseguang.springcloud.service.AttendanceTwoService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @描述 班牌人脸考勤2.0
 * @创建人 zm
 * @创建时间 2020/8/6 10:19
 */
@RestController
@RequestMapping("/brands")
public class AttendanceTwoController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());


    @Autowired
    private AttendanceTwoService attendanceService;

    /**
     * @描述 查询所有人员考勤状态
     * @创建人 zm
     * @创建时间 2020/2/22
     */
    @RequestMapping("/queryAttendUserStatusList")
    public Result queryAttendUserStatusList(@RequestParam(value = "deviceid") String deviceid,//设备id
                                            @RequestParam(value = "groupid", required = false) Integer groupid,//考勤组id
                                            @RequestParam(value = "grouptype", required = false) Integer grouptype,//考勤组类型 0学生考勤 1教室考勤
                                            @RequestParam(value = "shiftid", required = false) Integer shiftid,//班次id
                                            @RequestParam(value = "time", required = false) String time) {//dialog 时间段
        logger.info(" queryAttendUserStatusAll-->deviceid={},groupid={},grouptype={},shiftid={},time={}", deviceid, groupid, grouptype, shiftid, time);
        return attendanceService.queryAttendUserStatusList(deviceid, groupid, grouptype, shiftid, time);
    }


    /**
     * @描述 查询对应班牌所有考勤dialog时间
     * @创建人 zm
     * @创建时间 2020/2/20
     */
    @RequestMapping("/queryAttendGroupDialog")
    public Result queryAttendGroupDialogAll(
            @RequestParam(value = "deviceid") String deviceid) {//设备id
        return new Result(attendanceService.queryAttendGroupDialog(deviceid));
    }

    /**
     * @描述 班牌人脸考勤 添加考勤
     * @创建人 zm
     * @创建时间 2020/2/22
     */
    @RequestMapping("/addAttendStudent")
    public Result addAttend(@RequestParam(value = "deviceid") String deviceid,//设备id
                            @RequestParam(value = "userid") Integer userid,//考勤人员id'
                            @RequestParam(value = "groupid") Integer groupid,//考勤组id
                            @RequestParam(value = "grouptype") Integer grouptype,//考勤组类别
                            @RequestParam(value = "shiftid") Integer shiftid,//班次id
                            @RequestParam(value = "time") String time) {
        logger.info(" addAttend-->deviceid={},groupid={},userid={},shiftid={},time={}", deviceid, groupid, userid, shiftid, time);
        return attendanceService.addAttendStudent(deviceid, userid, groupid, grouptype, shiftid, time);
    }

}
